var app = getApp()
Page({
  data: {
    url : {
      getMyAppointment: app.url.baseUrl+"/my/Appointment"
    },
    pageNumber : -1,
    appList : [],
    isPage : true
  },
  onLoad: function () {
    
  },
  onShow:function(){
    this.setData({ pageNumber: -1, appList: [], isPage: true})
    this.getMyAppointment()
  },
  onReachBottom:function(){
    this.getMyAppointment()
  },
  getMyAppointment : function(){
    if (!this.data.isPage) {
     //提示
      return;
    }
    var that = this;
    var appList = this.data.appList
    var data = {pageNumber : this.data.pageNumber+1}
    app.ajax(this.data.url.getMyAppointment,data,function(res){
      var data = res.data.data
      var b = true
      if(data.length <=20)
        b = false

      for(var i = 0;i<data.length;i++){
        var obj = data[i]
        appList.push(obj)
      }
      that.setData({ appList: appList, isPage: b, pageNumber:that.data.pageNumber+=1})
    });
  },
  detail:function(e){
    var aid = e.currentTarget.dataset.aid;
    wx.navigateTo({
      url: 'detail/detail?aid='+aid,
    })
  },
  esc:function(e){
    var aid = e.currentTarget.dataset.aid;
    wx.navigateTo({
      url: 'esc/esc?aid=' + aid,
    })
  },
  shopInfo: function (e) {
    var shopId = e.currentTarget.dataset.shopid;
    wx.navigateTo({
      url: '../info/info?id='+shopId
    })
  },
  refreshData: function () {
    //初始化数据
    this.setData({ pageNumber: -1, appList: [], isPage: true });
    this.getMyAppointment()
  }
})

